package com.cxs.service.impl;

import com.cxs.anno.TargetDataSource;
import com.cxs.commons.DataSourceKey;
import com.cxs.domain.User;
import com.cxs.mapper.UserDAO;
import com.cxs.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author:chenxiaoshuang
 * @Date:2019/5/14 18:18
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDAO userDAO;

    @TargetDataSource(dataSourceKey = DataSourceKey.DB_MASTER)
    @Override
    public List<User> loadAllUser() {
        return userDAO.selectByExample(null);
    }

    @TargetDataSource(dataSourceKey = DataSourceKey.DB_MASTER)
    @Override
    public int insert(User user) {
        return userDAO.insert(user);
    }
}